|
|
|
|
|
|
|
lblGUIDAsStruct.Caption = ciddesc
lblRawData.Caption = GetDataString(VarPtr(cid), Len(cid))
End Sub |
|
|
|
|
|
|
|
|
The form creates a GUIDObject object that exposes function GetCLSID, which is able to return the object's CLSID. The lblGUIDAsStruct label displays each field in the CLSID structure independently. The GetDataString function (which is found in the ErrString module) displays data as hexadecimal values. |
|
|
|
|
|
|
|
|
The lblRawData label control displays the entire structure as it exists in memory. The reason for showing both the fields of the structure and the memory layout of the structure will become apparent later and isn't really relevant to the puzzle itself. |
|
|
|
|
|
|
|
|
The GUIDObject class exposes the GUIDObject object and contains the following code: |
|
|
|
|
|
|
|
|
' GUID Puzzle Example Class
'Copyright © 1998 by Desaware Inc. All Rights Reserved
Public Type CLSID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Declare Function CLSIDFromProgID Lib "ole32.dll" _
(ByVal lpszProgId As String, lpclsid As CLSID) As Long
Option Explicit
Public Function GetCLSID() As CLSID
Dim cid As CLSID
Dim res As Long
Dim MyProgramId As String
MyProgramId = "GUIDPuzzle.GUIDObject"
res = CLSIDFromProgID(MyProgramId, cid)
If res = 0 Then
GetCLSID = cid
Else
' What happens when you uncomment this?
' Err.Raise res
End If |
|
|
|
|
|